package com.itheima.d8_dateAPI;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 掌握JDK8新增的日期时间类
 */
public class Test02 {
    public static void main(String[] args) {
        LocalDateTime ldt = LocalDateTime.now();
        System.out.println(ldt);
        System.out.println(ldt.getYear());
        System.out.println(ldt.getHour());
        System.out.println(ldt.getDayOfYear());
        System.out.println("--------------------------");
        LocalDateTime ldt2 = ldt.plusDays(10);
        System.out.println(ldt2);
        System.out.println(ldt);
        System.out.println("--------------------------");
        System.out.println(ldt.equals(ldt2));
        System.out.println(ldt.isAfter(ldt2));
        System.out.println(ldt.isBefore(ldt2));
        System.out.println("==========================");

        //日期格式化对象
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
        String ss = dtf.format(ldt);
        System.out.println(ss);
    }
}
